package com.auth.exception;

import com.auth.web.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: 王霄
 * @date: 2022/1/21 12:54
 **/
@RestControllerAdvice
@Slf4j
public class ExceptionProcessor {

    @ExceptionHandler(value = NoAuthException.class)
    public R<?> handleAuthorizationException(NoAuthException e) {
        log.error(e.getMessage(), e);
        return R.fail(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public R<?> handleException(Exception e) {
        log.error(e.getMessage(), e);
        return R.fail(e.getMessage());
    }
}